home *** CD-ROM | disk | FTP | other *** search
- /* ******************************************************************** */
- /* C code generated by: */
- /* Visual Arts Version 2.1 */
- /* Copyright 1994-95 Danny Y. Wong All rights reserved */
- /* Calgary, Alberta (CANADA) */
- /* Partial of the code is copyright by Jaba Development */
- /* ******************************************************************** */
-
- #include <VisualArts.h>
- #include <clib/VisualArts_protos.h>
-
- #define ID_ok 0
- #define ID_HD 1
- #define ID_cancel 2
- #define ID_cd 3
- #define ID_model 4
- #define ID_ObjID9 5
-
- #define ContextNumGads 6
-
- #include "Context_func.c"
-
- int okObj(struct VAobject VAObject);
- int HDObj(struct VAobject VAObject);
- int cancelObj(struct VAobject VAObject);
- int cdObj(struct VAobject VAObject);
- int modelObj(struct VAobject VAObject);
-
- int GetPubScreen(void);
- void ClosePubScreen(void);
- int OpenContextWindow(char windtitle[]);
- void CloseContextWindow(void);
- int ContextHandler(void);
- int ContextMainHandler(void);
- void DrawContextObjs(void);
- int main(int argc, char *argv[]);
-
- extern UWORD VA_WindHi, VA_WindWid;
- UBYTE *PubScrName = "Workbench";
- struct DrawInfo *ScrDrawInfo = NULL;
- APTR VisualInfo = NULL;
- struct Screen *Scr = NULL;
- struct Window *ContextWnd = NULL;
- struct Gadget *ContextGList = NULL;
- struct Gadget *ContextGadgets[ContextNumGads];
- struct IntuiMessage ContextMsg;
- UWORD ContextLeft = 143;
- UWORD ContextTop = 58;
- UWORD ContextWidth = 247;
- UWORD ContextHeight = 72;
- struct TextAttr topaz8 = { (STRPTR)"topaz.font", 8, 0x00, 0x01 };
- struct TextAttr topaz800 = { (STRPTR)"topaz.font", 8, 0x00, 0x00 };
-
- UBYTE *ModelsLabels[] = {
- (UBYTE *)"Amiga 500",
- (UBYTE *)"Amiga 600",
- (UBYTE *)"Amiga 1000",
- (UBYTE *)"Amiga 1200",
- (UBYTE *)"Amiga 2000",
- (UBYTE *)"Amiga 2500",
- (UBYTE *)"Amiga 3000",
- (UBYTE *)"Amiga 4000",
- (UBYTE *)"Amiga CDTV",
- (UBYTE *)"Amiga CD32",
- NULL
- };
-
- WORD ContextGadTypes[] = {
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- CHECKBOX_KIND,
- LISTVIEW_KIND,
- TEXT_KIND,
- };
-
- struct NewGadget ContextNGads[] = {
- 3, 46, 52, 11, (UBYTE *)"OK",&topaz800, ID_ok, PLACETEXT_IN, NULL, (APTR)okObj,
- 134, 32, 87, 11, (UBYTE *)"Hard Drive",&topaz800, ID_HD, PLACETEXT_IN, NULL, (APTR)HDObj,
- 170, 46, 52, 11, (UBYTE *)"Cancel",&topaz800, ID_cancel, PLACETEXT_IN, NULL, (APTR)cancelObj,
- 195, 1, 26, 11, (UBYTE *)"CD-ROM", &topaz800, ID_cd, PLACETEXT_LEFT, NULL, (APTR)cdObj,
- 3, 1, 119, 44, (UBYTE *)"", &topaz800, ID_model, PLACETEXT_ABOVE, NULL, (APTR)modelObj,
- 134, 16, 87, 12, (UBYTE *)"", &topaz800, ID_ObjID9, PLACETEXT_LEFT, NULL, NULL,
- };
-
- ULONG ContextNTags[] = {
- TAG_DONE,
- TAG_DONE,
- TAG_DONE,
- (GTCB_Checked), TRUE, TAG_DONE,
- (GTLV_Labels), NULL, (GTLV_Top), 0, (GTLV_ScrollWidth), 16, (LAYOUTA_Spacing), 0, TAG_DONE,
- (GTTX_Text),(ULONG)"Amiga", (GTTX_Border), TRUE, TAG_DONE,
- };
-
- UBYTE *ContextContextVars[] = { /* DO NOT MODIFY */
- (UBYTE *)"2 ",
- (UBYTE *)"0 ",
- (UBYTE *)"2 ",
- (UBYTE *)"1 ",
- (UBYTE *)"0 ",
- (UBYTE *)"Amiga ",
- };
-
- ULONG ContextContextTypes[] = {
- VA_MoveY ,
- VA_MoveX | VA_MoveY ,
- VA_MoveX | VA_MoveY ,
- VA_MoveX ,
- VA_ExpandX | VA_ExpandY ,
- VA_MoveX | VA_MoveY ,
- TAG_DONE
- };
-
-
- int GetPubScreen(void)
- {
- if (!(Scr = LockPubScreen(PubScrName)))
- return(1L);
-
- if (!(VisualInfo = GetVisualInfo(Scr, TAG_DONE)))
- return(2L);
-
- if (!(ScrDrawInfo = GetScreenDrawInfo(Scr)))
- return(3L);
- return(0L);
- }
-
- void ClosePubScreen(void)
- {
- if (VisualInfo)
- FreeVisualInfo(VisualInfo);
- if (Scr)
- UnlockPubScreen(NULL, Scr);
- if (ScrDrawInfo)
- FreeScreenDrawInfo(Scr, ScrDrawInfo);
- }
-
- int OpenContextWindow(char windtitle[80])
- {
- struct NewGadget NewGad;
- struct Gadget *Gad;
- register UWORD i, j;
- UWORD offsetx = Scr->WBorLeft;
- UWORD offsety = Scr->WBorTop + Scr->Font->ta_YSize + 1;
-
- if (!(Gad = CreateContext(&ContextGList)))
- return(1L);
-
- for (i=0, j=0; i < ContextNumGads; i++)
- {
- CopyMem((char *)&ContextNGads[i], (char *)&NewGad, (long)sizeof(struct NewGadget));
-
- NewGad.ng_VisualInfo = VisualInfo;
- NewGad.ng_LeftEdge += offsetx;
- NewGad.ng_TopEdge += offsety;
-
- ContextGadgets[i] = Gad = CreateGadgetA((ULONG)ContextGadTypes[i], Gad, &NewGad,
- (struct TagItem *)&ContextNTags[j]);
- while (ContextNTags[j])
- j +=2;
- j++;
- if (!Gad)
- return(2L);
- }
- ContextGadgets[1]->Activation |= GACT_TOGGLESELECT;
- if (!(ContextWnd = OpenWindowTags(NULL,
- WA_Left, ContextLeft,
- WA_Top, ContextTop,
- WA_Width, ContextWidth,
- WA_Height, ContextHeight + kWindowOffSetY,
- WA_NewLookMenus, TRUE,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_GADGETUP | IDCMP_GADGETDOWN | IDCMP_INTUITICKS ,
- WA_Flags, WFLG_SIZEGADGET | WFLG_SIZEBRIGHT | WFLG_DEPTHGADGET |
- WFLG_CLOSEGADGET | WFLG_SMART_REFRESH |
- WFLG_RMBTRAP | WFLG_ACTIVATE |
- WFLG_DRAGBAR ,
- WA_Gadgets, ContextGList,
- WA_Title, windtitle,
- WA_ScreenTitle, "Visual Arts V2.2 Copyright 1994-95 Danny Y. Wong All Rights Reserved.",
- WA_PubScreen, Scr,
- WA_MinWidth, 247,
- WA_MinHeight, 72,
- WA_MaxWidth, 640,
- WA_MaxHeight, 200,
- TAG_DONE)))
- return(3L);
-
- CreateContextLists();
- GT_RefreshWindow(ContextWnd, NULL);
- RefreshGadgets(ContextGadgets[0], ContextWnd, NULL);
- GT_SetGadgetAttrs(ContextGadgets[4], ContextWnd, NULL,
- GTLV_Labels, ContextLists[0], TAG_END);
- VA_WindHi = ContextWnd->Height;
- VA_WindWid = ContextWnd->Width;
- InitLayoutVars(ContextContextTypes, ContextContextVars);
- return(0L);
- }
-
- void CloseContextWindow(void)
- {
- if (ContextWnd)
- CloseWindow(ContextWnd);
- if (ContextGList)
- FreeGadgets(ContextGList);
- }
-
- int ContextHandler(void)
- {
- struct IntuiMessage *msg;
- struct VAobject VAObject;
- int running = 1;
- int rc = 0;
- int (*func)(struct VAobject VAObject);
- ULONG class;
- UWORD code;
-
- while (msg=GT_GetIMsg(ContextWnd->UserPort))
- {
- CopyMem((char *)msg, (char *)&ContextMsg, (long)sizeof(struct IntuiMessage));
- class = msg->Class;
- code = msg->Code;
-
- VAObject.va_Window = (struct Window *)ContextWnd;
- VAObject.va_Gadget = (struct Gadget *)msg->IAddress;
- VAObject.va_IntuiMsg = (struct IntuiMessage *)msg;
- VAObject.va_Flags = 0;
- VAObject.va_UserData = 0;
-
- GT_ReplyIMsg(msg);
- switch(class)
- {
-
- case IDCMP_NEWSIZE:
- rc= VA_GadLayout(ContextWnd, ContextGList, ContextGadgets,
- ContextContextTypes, ContextGadTypes,
- (struct NewGadget *)&ContextNGads, ContextNTags, ContextLists, ContextContextVars);
- break;
-
- case IDCMP_CLOSEWINDOW:
- return(0);
- break;
-
- case IDCMP_GADGETDOWN: /* GADGETDOWN is for MX gadgets */
-
- case IDCMP_GADGETUP:
- func = (void *)((struct Gadget *)ContextMsg.IAddress)->UserData;
- if (func != NULL)
- running = func(VAObject);
- break;
-
- }
- }
- return(running);
- }
-
- int ContextMainHandler(void)
- {
- int running = 1;
- ULONG windsig, signals;
-
- windsig = 1L << ContextWnd->UserPort->mp_SigBit;
-
- while (running == 1)
- {
- signals = Wait( windsig );
- if (signals & windsig)
- {
- running = ContextHandler();
- }
- }
- return(running);
- }
-
- int main(int argc, char *argv[])
- {
- int rc;
-
- if (!(GetPubScreen()))
- {
- for (rc=0; rc < 1; rc++)
- ContextLists[rc]=GetNewList();
- if (!(OpenContextWindow("Context Sensitive")))
- {
- rc = ContextMainHandler();
- CloseContextWindow();
- }
- for (rc=0; rc < 1; rc++)
- FreeList(ContextLists[rc]);
- ClosePubScreen();
- }
- return(0L);
- }
-